Add transform context for annotating compiler optimizations#216
Merged
Conversation
Contributor
|
gnidan
force-pushed
the
transform-context
branch
11 times, most recently
from
July 16, 2026 04:16
2a8509d to
0e59810
Compare
Introduce the `transform` context: a flat sibling key on an instruction listing the optimization passes (fold, coalesce, tailcall, inline) the compiler applied to it, so a debugger can distinguish compiler-synthesized code from the source the user wrote. Adds the schema, the format TypeScript type, and the spec page, and registers the context page in the docs schema index.
Emit `transform: ["tailcall"]` on the TCO back-edge JUMP, alongside the invoke/return pair it already carries, so a debugger sees the pair as a tail-call-optimized back-edge rather than a real frame push/pop and does not invent a spurious frame. Render it in the tracer drawer — an optimizer-level (O0-O3) selector and a tail-call-aware call stack — and document it with a tracing example and a walkthrough homed in the trace playground. Introduces the shared `Ir.Utils.addTransform` helper — the fold, coalesce, and inline emitters all route through it — and the transform-emission test file (`transform-contexts.test.ts`, with the `countTransform` helper), covering the tailcall marker: absent at O0/O1, present at O2/O3.
Mark constant-folded values with `transform: ["fold"]` through a shared `addTransform` helper, so the tracer can show a value as a compile-time-evaluated constant rather than source. The marker composes with later passes into a multiset (e.g. `["fold", "coalesce"]`).
Mark the SHL/OR field-packing sequence produced by read-write merging with `transform: ["coalesce"]`, so a packed-storage write reads as compiler-synthesized rather than source the user wrote. Composes with a folded value into `["fold", "coalesce"]`.
gnidan
force-pushed
the
transform-context
branch
from
July 16, 2026 04:22
0e59810 to
c8355db
Compare
Add the function-inlining transform end to end: - spec the inlined-call virtual-activation contract — push/pop pairing via the virtual invoke/return versus the per-instruction `inline` membership marker; - add the bugc inlining pass (level 2): splice eligible leaf callees into their call sites, emit `transform: ["inline"]` on the spliced body, and bracket it with a virtual invoke/return; bracket those boundary ops in evmgen so the activation nests correctly; - reconstruct the inline virtual activations in the tracer's call stack; - add the inlining showcase examples and the trace-playground section.
Correlate activations with an `activation` identifier on invoke, return, and revert: the invoke that opens an activation and the return or revert that closes it carry the same value, so a debugger pairs a call with its return independent of trace order. It lives inside the invoke/return/revert object, keeping a tail call's two facts flat without a `gather`.
Show the tailcall and inline transform annotations inline in the tracer's instruction list, so the optimizer passes applied to each instruction are visible as you step through the trace.
gnidan
force-pushed
the
transform-context
branch
from
July 16, 2026 04:28
c8355db to
e08afea
Compare
gnidan
marked this pull request as ready for review
July 16, 2026 04:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
transformcontext that records which compiler optimizations produced an instruction, and wires it end to end — from the bugc emitters to the tracer — so a debugger can tell compiler-synthesized code from the source the user wrote.Format
transformcontext — a flat sibling key listing the optimization passes applied to an instruction (fold,coalesce,tailcall,inline), with its schema, TypeScript type, and spec page. The identifier set is extensible.invoke/returnbracket with the code target omitted and marks the spliced body withtransform: ["inline"], so a debugger reconstructs a virtual activation without a real frame.activationidentifier — the openinginvokeand its closingreturn/revertcarry the same value, pairing a call with its return independent of trace order.Implementation
Ir.Utils.addTransformhelper:foldon constant folding,coalesceon read-write merging,tailcallon the TCO back-edge, andinlinefrom a new function-inlining pass that splices eligible leaf callees into their call sites and brackets the body with a virtual invoke/return.